import java.util.Scanner;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Admin
 * Date: 2022-12-09
 * Time: 18:03
 */
public class Demo2 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        while(scan.hasNextInt()) {

            int n = scan.nextInt();
            scan.nextLine();

            Stack<Integer> que = new Stack<>();
            int result = 0;

            for(int i = 0; i < n; i++) {
                String str = scan.next();

                if(!(str.equals("+") || str.equals("-") || str.equals("*") || str.equals("/"))) {
                    que.push(Integer.valueOf(str));
                }else {
                    int num1 = que.peek();
                    que.pop();
                    int num2 = que.peek();
                    que.pop();
                    switch(str) {
                        case "+":
                            result = num2 + num1;
                            que.push(result);
                            break;
                        case "-":
                            result = num2 - num1;
                            que.push(result);
                            break;
                        case "*":
                            result = num2 * num1;
                            que.push(result);
                            break;
                        case "/":
                            result = num2 / num1;
                            que.push(result);
                            break;

                    }
                }
            }
            System.out.println(result);
        }
    }
}
